.class Lcom/renren/api/connect/android/AccessTokenManager;
.super Ljava/lang/Object;
.source "AccessTokenManager.java"

# interfaces
.implements Landroid/os/Parcelable;


# static fields
.field public static final CREATOR:Landroid/os/Parcelable$Creator; = null
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Landroid/os/Parcelable$Creator",
            "<",
            "Lcom/renren/api/connect/android/AccessTokenManager;",
            ">;"
        }
    .end annotation
.end field

.field private static final KEY_ACCESS_TOKEN:Ljava/lang/String; = "renren_token_manager_access_token"

.field private static final KEY_SESSION_KEY:Ljava/lang/String; = "renren_token_manager_session_key"

.field private static final KEY_SESSION_KEY_EXPIRE_TIME:Ljava/lang/String; = "renren_token_manager_session_key_expire_time"

.field private static final KEY_SESSION_SECRET:Ljava/lang/String; = "renren_token_manager_session_secret"

.field private static final KEY_UID:Ljava/lang/String; = "renren_token_manager_user_id"

.field private static final ONE_HOUR:J = 0x36ee80L

.field private static final RENREN_SDK_CONFIG:Ljava/lang/String; = "renren_sdk_config"

.field private static final RENREN_SDK_CONFIG_PROP_ACCESS_TOKEN:Ljava/lang/String; = "renren_sdk_config_prop_access_token"

.field private static final RENREN_SDK_CONFIG_PROP_CREATE_TIME:Ljava/lang/String; = "renren_sdk_config_prop_create_time"

.field private static final RENREN_SDK_CONFIG_PROP_EXPIRE_SECONDS:Ljava/lang/String; = "renren_sdk_config_prop_expire_secends"

.field private static final RENREN_SDK_CONFIG_PROP_SESSION_CREATE_TIME:Ljava/lang/String; = "renren_sdk_config_prop_session_create_time"

.field private static final RENREN_SDK_CONFIG_PROP_SESSION_KEY:Ljava/lang/String; = "renren_sdk_config_prop_session_key"

.field private static final RENREN_SDK_CONFIG_PROP_SESSION_SECRET:Ljava/lang/String; = "renren_sdk_config_prop_session_secret"

.field private static final RENREN_SDK_CONFIG_PROP_USER_ID:Ljava/lang/String; = "renren_sdk_config_prop_user_id"

.field private static final SESSION_KEY_URL:Ljava/lang/String; = "http://graph.renren.com/renren_api/session_key"


# instance fields
.field private accessToken:Ljava/lang/String;

.field private context:Landroid/content/Context;

.field private expireTime:J

.field private sessionKey:Ljava/lang/String;

.field private sessionSecret:Ljava/lang/String;

.field private uid:J


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 415
    new-instance v0, Lcom/renren/api/connect/android/AccessTokenManager$1;

    invoke-direct {v0}, Lcom/renren/api/connect/android/AccessTokenManager$1;-><init>()V

    sput-object v0, Lcom/renren/api/connect/android/AccessTokenManager;->CREATOR:Landroid/os/Parcelable$Creator;

    .line 26
    return-void
.end method

.method constructor <init>(Landroid/content/Context;)V
    .locals 2
    .parameter "context"

    .prologue
    const/4 v0, 0x0

    .line 76
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 60
    iput-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 64
    iput-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 69
    const-wide/16 v0, 0x0

    iput-wide v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 77
    iput-object p1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    .line 78
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->compareWithConfig()V

    .line 79
    return-void
.end method

.method public constructor <init>(Landroid/os/Parcel;)V
    .locals 3
    .parameter "in"

    .prologue
    const/4 v1, 0x0

    .line 81
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 60
    iput-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 64
    iput-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 69
    const-wide/16 v1, 0x0

    iput-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 82
    sget-object v1, Landroid/os/Bundle;->CREATOR:Landroid/os/Parcelable$Creator;

    invoke-interface {v1, p1}, Landroid/os/Parcelable$Creator;->createFromParcel(Landroid/os/Parcel;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/os/Bundle;

    .line 83
    .local v0, bundle:Landroid/os/Bundle;
    if-eqz v0, :cond_0

    .line 84
    const-string v1, "renren_token_manager_access_token"

    invoke-virtual {v0, v1}, Landroid/os/Bundle;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 85
    const-string v1, "renren_token_manager_session_key"

    invoke-virtual {v0, v1}, Landroid/os/Bundle;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    .line 86
    const-string v1, "renren_token_manager_session_secret"

    invoke-virtual {v0, v1}, Landroid/os/Bundle;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 87
    const-string v1, "renren_token_manager_session_key_expire_time"

    invoke-virtual {v0, v1}, Landroid/os/Bundle;->getLong(Ljava/lang/String;)J

    move-result-wide v1

    iput-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 88
    const-string v1, "renren_token_manager_user_id"

    invoke-virtual {v0, v1}, Landroid/os/Bundle;->getLong(Ljava/lang/String;)J

    move-result-wide v1

    iput-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    .line 90
    :cond_0
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->compareWithConfig()V

    .line 91
    return-void
.end method

.method static synthetic access$0(Lcom/renren/api/connect/android/AccessTokenManager;)Ljava/lang/String;
    .locals 1
    .parameter

    .prologue
    .line 62
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$1(Lcom/renren/api/connect/android/AccessTokenManager;)Ljava/lang/String;
    .locals 1
    .parameter

    .prologue
    .line 64
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$2(Lcom/renren/api/connect/android/AccessTokenManager;)J
    .locals 2
    .parameter

    .prologue
    .line 74
    iget-wide v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    return-wide v0
.end method

.method static synthetic access$3(Lcom/renren/api/connect/android/AccessTokenManager;)V
    .locals 0
    .parameter

    .prologue
    .line 230
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    return-void
.end method

.method private clearSessionParams()V
    .locals 7

    .prologue
    const-wide/16 v5, 0x0

    const/4 v4, 0x0

    .line 357
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    const-string v2, "renren_sdk_config"

    .line 358
    const/4 v3, 0x0

    .line 357
    invoke-virtual {v1, v2, v3}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v1

    .line 358
    invoke-interface {v1}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    .line 359
    .local v0, editor:Landroid/content/SharedPreferences$Editor;
    const-string v1, "renren_sdk_config_prop_session_key"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 360
    const-string v1, "renren_sdk_config_prop_session_secret"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 361
    const-string v1, "renren_sdk_config_prop_expire_secends"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 362
    const-string v1, "renren_sdk_config_prop_session_create_time"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 363
    const-string v1, "renren_sdk_config_prop_user_id"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 364
    iput-object v4, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    .line 365
    iput-object v4, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 366
    iput-wide v5, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 367
    iput-wide v5, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    .line 368
    invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 369
    return-void
.end method

.method private compareWithConfig()V
    .locals 4

    .prologue
    .line 183
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    if-nez v1, :cond_0

    .line 208
    :goto_0
    return-void

    .line 187
    :cond_0
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    .line 188
    const-string v2, "renren_sdk_config"

    const/4 v3, 0x0

    .line 187
    invoke-virtual {v1, v2, v3}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v0

    .line 189
    .local v0, sp:Landroid/content/SharedPreferences;
    new-instance v1, Lcom/renren/api/connect/android/AccessTokenManager$2;

    invoke-direct {v1, p0, v0}, Lcom/renren/api/connect/android/AccessTokenManager$2;-><init>(Lcom/renren/api/connect/android/AccessTokenManager;Landroid/content/SharedPreferences;)V

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences;->registerOnSharedPreferenceChangeListener(Landroid/content/SharedPreferences$OnSharedPreferenceChangeListener;)V

    goto :goto_0
.end method

.method private exchangeSessionKey(Ljava/lang/String;)V
    .locals 14
    .parameter "accessToken"

    .prologue
    .line 276
    if-eqz p1, :cond_0

    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v0

    const/4 v1, 0x1

    if-ge v0, v1, :cond_1

    .line 308
    :cond_0
    :goto_0
    return-void

    .line 279
    :cond_1
    new-instance v12, Landroid/os/Bundle;

    invoke-direct {v12}, Landroid/os/Bundle;-><init>()V

    .line 280
    .local v12, params:Landroid/os/Bundle;
    const-string v0, "oauth_token"

    invoke-virtual {v12, v0, p1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 281
    const-string v0, "http://graph.renren.com/renren_api/session_key"

    const-string v1, "POST"

    invoke-static {v0, v1, v12}, Lcom/renren/api/connect/android/Util;->openUrl(Ljava/lang/String;Ljava/lang/String;Landroid/os/Bundle;)Ljava/lang/String;

    move-result-object v13

    .line 283
    .local v13, sk:Ljava/lang/String;
    :try_start_0
    new-instance v11, Lorg/json/JSONObject;

    invoke-direct {v11, v13}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 284
    .local v11, obj:Lorg/json/JSONObject;
    const-string v0, "error"

    const/4 v1, 0x0

    invoke-virtual {v11, v0, v1}, Lorg/json/JSONObject;->optString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v10

    .line 285
    .local v10, error:Ljava/lang/String;
    if-eqz v10, :cond_2

    .line 286
    new-instance v0, Lcom/renren/api/connect/android/exception/RenrenError;

    invoke-virtual {v11}, Lorg/json/JSONObject;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Lcom/renren/api/connect/android/exception/RenrenError;-><init>(Ljava/lang/String;)V

    throw v0
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    .line 305
    .end local v10           #error:Ljava/lang/String;
    .end local v11           #obj:Lorg/json/JSONObject;
    :catch_0
    move-exception v9

    .line 306
    .local v9, e:Lorg/json/JSONException;
    new-instance v0, Ljava/lang/RuntimeException;

    invoke-virtual {v9}, Lorg/json/JSONException;->getMessage()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1, v9}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v0

    .line 288
    .end local v9           #e:Lorg/json/JSONException;
    .restart local v10       #error:Ljava/lang/String;
    .restart local v11       #obj:Lorg/json/JSONObject;
    :cond_2
    :try_start_1
    const-string v0, "renren_token"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v0

    .line 289
    const-string v1, "session_key"

    .line 288
    invoke-virtual {v0, v1}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    .line 290
    const-string v0, "renren_token"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v0

    .line 291
    const-string v1, "session_secret"

    .line 290
    invoke-virtual {v0, v1}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 293
    const-string v0, "user"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v0

    const-string v1, "id"

    invoke-virtual {v0, v1}, Lorg/json/JSONObject;->getLong(Ljava/lang/String;)J

    move-result-wide v0

    iput-wide v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    .line 295
    const-string v0, "renren_token"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v0

    .line 296
    const-string v1, "expires_in"

    .line 295
    invoke-virtual {v0, v1}, Lorg/json/JSONObject;->getLong(Ljava/lang/String;)J

    move-result-wide v0

    .line 296
    const-wide/16 v7, 0x3e8

    .line 295
    mul-long v5, v0, v7

    .line 297
    .local v5, expires:J
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    .line 298
    .local v3, current:J
    add-long v0, v3, v5

    iput-wide v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 300
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    iget-object v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    iget-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    move-object v0, p0

    invoke-direct/range {v0 .. v8}, Lcom/renren/api/connect/android/AccessTokenManager;->storeSessionParams(Ljava/lang/String;Ljava/lang/String;JJJ)V

    .line 302
    const-string v0, "Renren-SDK"

    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "---login success sessionKey:"

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 303
    const-string v2, " expires:"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v5, v6}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " sessionSecret:"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 304
    const-string v2, " uid:"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    invoke-virtual {v1, v7, v8}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 302
    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_1
    .catch Lorg/json/JSONException; {:try_start_1 .. :try_end_1} :catch_0

    goto/16 :goto_0
.end method

.method private declared-synchronized initSessionKey()V
    .locals 10

    .prologue
    .line 231
    monitor-enter p0

    :try_start_0
    iget-object v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    const-string v8, "renren_sdk_config"

    .line 232
    const/4 v9, 0x0

    .line 231
    invoke-virtual {v7, v8, v9}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v6

    .line 233
    .local v6, sp:Landroid/content/SharedPreferences;
    const-string v7, "renren_sdk_config_prop_session_key"

    const/4 v8, 0x0

    invoke-interface {v6, v7, v8}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    .line 234
    const-string v7, "renren_sdk_config_prop_session_secret"

    const/4 v8, 0x0

    invoke-interface {v6, v7, v8}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 235
    const-string v7, "renren_sdk_config_prop_user_id"

    const-wide/16 v8, 0x0

    invoke-interface {v6, v7, v8, v9}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J

    move-result-wide v7

    iput-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    .line 236
    const-string v7, "renren_sdk_config_prop_expire_secends"

    const-wide/16 v8, 0x0

    invoke-interface {v6, v7, v8, v9}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J

    move-result-wide v4

    .line 237
    .local v4, expires:J
    const-string v7, "renren_sdk_config_prop_session_create_time"

    const-wide/16 v8, 0x0

    invoke-interface {v6, v7, v8, v9}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J

    move-result-wide v0

    .line 238
    .local v0, createTime:J
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v2

    .line 239
    .local v2, current:J
    add-long v7, v0, v4

    iput-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 242
    iget-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    cmp-long v7, v7, v2

    if-gez v7, :cond_0

    .line 243
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearSessionParams()V

    .line 244
    const/4 v7, 0x0

    iput-object v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    .line 245
    const/4 v7, 0x0

    iput-object v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 246
    const-wide/16 v7, 0x0

    iput-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 247
    const-wide/16 v7, 0x0

    iput-wide v7, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 249
    :cond_0
    monitor-exit p0

    return-void

    .line 231
    .end local v0           #createTime:J
    .end local v2           #current:J
    .end local v4           #expires:J
    .end local v6           #sp:Landroid/content/SharedPreferences;
    :catchall_0
    move-exception v7

    monitor-exit p0

    throw v7
.end method

.method private restoreAccessToken()Ljava/lang/String;
    .locals 13

    .prologue
    const/4 v8, 0x0

    .line 372
    iget-object v9, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    const-string v10, "renren_sdk_config"

    .line 373
    const/4 v11, 0x0

    .line 372
    invoke-virtual {v9, v10, v11}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v7

    .line 374
    .local v7, sp:Landroid/content/SharedPreferences;
    const-string v9, "renren_sdk_config_prop_access_token"

    invoke-interface {v7, v9, v8}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 376
    .local v0, accessToken:Ljava/lang/String;
    if-nez v0, :cond_1

    move-object v0, v8

    .line 386
    .end local v0           #accessToken:Ljava/lang/String;
    :cond_0
    :goto_0
    return-object v0

    .line 379
    .restart local v0       #accessToken:Ljava/lang/String;
    :cond_1
    const-string v9, "renren_sdk_config_prop_create_time"

    const-wide/16 v10, 0x0

    invoke-interface {v7, v9, v10, v11}, Landroid/content/SharedPreferences;->getLong(Ljava/lang/String;J)J

    move-result-wide v1

    .line 380
    .local v1, createTime:J
    const-string v9, "\\."

    invoke-virtual {v0, v9}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v9

    const/4 v10, 0x2

    aget-object v9, v9, v10

    invoke-static {v9}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J

    move-result-wide v9

    const-wide/16 v11, 0x3e8

    mul-long v5, v9, v11

    .line 381
    .local v5, life:J
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    .line 382
    .local v3, currenct:J
    add-long v9, v1, v5

    const-wide/32 v11, 0x36ee80

    sub-long v11, v3, v11

    cmp-long v9, v9, v11

    if-gez v9, :cond_0

    .line 383
    invoke-virtual {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearPersistSession()V

    move-object v0, v8

    .line 384
    goto :goto_0
.end method

.method private storeAccessToken(Ljava/lang/String;)V
    .locals 4
    .parameter "accessToken"

    .prologue
    .line 315
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    const-string v2, "renren_sdk_config"

    .line 316
    const/4 v3, 0x0

    .line 315
    invoke-virtual {v1, v2, v3}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v1

    .line 316
    invoke-interface {v1}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    .line 317
    .local v0, editor:Landroid/content/SharedPreferences$Editor;
    if-eqz p1, :cond_0

    .line 318
    const-string v1, "renren_sdk_config_prop_access_token"

    invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 319
    const-string v1, "renren_sdk_config_prop_create_time"

    .line 320
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v2

    .line 319
    invoke-interface {v0, v1, v2, v3}, Landroid/content/SharedPreferences$Editor;->putLong(Ljava/lang/String;J)Landroid/content/SharedPreferences$Editor;

    .line 324
    :goto_0
    invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 325
    return-void

    .line 322
    :cond_0
    invoke-virtual {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearPersistSession()V

    goto :goto_0
.end method

.method private storeSessionParams(Ljava/lang/String;Ljava/lang/String;JJJ)V
    .locals 4
    .parameter "sessionKey"
    .parameter "sessionSecret"
    .parameter "sessionCreateTime"
    .parameter "expires"
    .parameter "uid"

    .prologue
    .line 337
    if-eqz p1, :cond_0

    if-nez p2, :cond_1

    .line 338
    :cond_0
    invoke-virtual {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearPersistSession()V

    .line 351
    :goto_0
    return-void

    .line 342
    :cond_1
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    const-string v2, "renren_sdk_config"

    .line 343
    const/4 v3, 0x0

    .line 342
    invoke-virtual {v1, v2, v3}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v1

    .line 343
    invoke-interface {v1}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    .line 345
    .local v0, editor:Landroid/content/SharedPreferences$Editor;
    const-string v1, "renren_sdk_config_prop_session_key"

    invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 346
    const-string v1, "renren_sdk_config_prop_session_secret"

    invoke-interface {v0, v1, p2}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 347
    const-string v1, "renren_sdk_config_prop_expire_secends"

    invoke-interface {v0, v1, p5, p6}, Landroid/content/SharedPreferences$Editor;->putLong(Ljava/lang/String;J)Landroid/content/SharedPreferences$Editor;

    .line 348
    const-string v1, "renren_sdk_config_prop_session_create_time"

    invoke-interface {v0, v1, p3, p4}, Landroid/content/SharedPreferences$Editor;->putLong(Ljava/lang/String;J)Landroid/content/SharedPreferences$Editor;

    .line 349
    const-string v1, "renren_sdk_config_prop_user_id"

    invoke-interface {v0, v1, p7, p8}, Landroid/content/SharedPreferences$Editor;->putLong(Ljava/lang/String;J)Landroid/content/SharedPreferences$Editor;

    .line 350
    invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z

    goto :goto_0
.end method

.method private updateAccessToken(Ljava/lang/String;Z)V
    .locals 5
    .parameter "accessToken"
    .parameter "isPersist"

    .prologue
    .line 252
    if-eqz p1, :cond_0

    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v1

    const/4 v2, 0x1

    if-ge v1, v2, :cond_1

    .line 273
    :cond_0
    :goto_0
    return-void

    .line 255
    :cond_1
    iput-object p1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 258
    :try_start_0
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    .line 260
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v1, :cond_2

    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-eqz v1, :cond_2

    iget-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    cmp-long v1, v1, v3

    if-gez v1, :cond_3

    .line 261
    :cond_2
    invoke-direct {p0, p1}, Lcom/renren/api/connect/android/AccessTokenManager;->exchangeSessionKey(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 268
    :cond_3
    :goto_1
    if-eqz p2, :cond_4

    .line 269
    invoke-direct {p0, p1}, Lcom/renren/api/connect/android/AccessTokenManager;->storeAccessToken(Ljava/lang/String;)V

    goto :goto_0

    .line 263
    :catch_0
    move-exception v0

    .line 264
    .local v0, e:Ljava/lang/Exception;
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 265
    invoke-virtual {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearPersistSession()V

    goto :goto_1

    .line 271
    .end local v0           #e:Ljava/lang/Exception;
    :cond_4
    invoke-virtual {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearPersistSession()V

    goto :goto_0
.end method


# virtual methods
.method clearPersistSession()V
    .locals 7

    .prologue
    const-wide/16 v5, 0x0

    const/4 v4, 0x0

    .line 211
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    const-string v2, "renren_sdk_config"

    .line 212
    const/4 v3, 0x0

    .line 211
    invoke-virtual {v1, v2, v3}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v1

    .line 212
    invoke-interface {v1}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    .line 213
    .local v0, editor:Landroid/content/SharedPreferences$Editor;
    const-string v1, "renren_sdk_config_prop_access_token"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 214
    const-string v1, "renren_sdk_config_prop_create_time"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 215
    const-string v1, "renren_sdk_config_prop_session_key"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 216
    const-string v1, "renren_sdk_config_prop_session_secret"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 217
    const-string v1, "renren_sdk_config_prop_expire_secends"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 218
    const-string v1, "renren_sdk_config_prop_user_id"

    invoke-interface {v0, v1}, Landroid/content/SharedPreferences$Editor;->remove(Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    .line 219
    invoke-interface {v0}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 220
    iput-object v4, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 221
    iput-object v4, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    .line 222
    iput-object v4, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    .line 223
    iput-wide v5, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    .line 224
    iput-wide v5, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    .line 225
    return-void
.end method

.method public describeContents()I
    .locals 1

    .prologue
    .line 391
    const/4 v0, 0x0

    return v0
.end method

.method getAccessToken()Ljava/lang/String;
    .locals 1

    .prologue
    .line 94
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->restoreAccessToken()Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 95
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    return-object v0
.end method

.method getSessionKey()Ljava/lang/String;
    .locals 4

    .prologue
    .line 99
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-nez v0, :cond_1

    .line 100
    :cond_0
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    .line 103
    :cond_1
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    iget-wide v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    cmp-long v0, v0, v2

    if-lez v0, :cond_2

    .line 104
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearSessionParams()V

    .line 107
    :cond_2
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    return-object v0
.end method

.method getSessionSecret()Ljava/lang/String;
    .locals 4

    .prologue
    .line 111
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-nez v0, :cond_1

    .line 112
    :cond_0
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    .line 115
    :cond_1
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    iget-wide v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    cmp-long v0, v0, v2

    if-lez v0, :cond_2

    .line 116
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearSessionParams()V

    .line 118
    :cond_2
    iget-object v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    return-object v0
.end method

.method getUid()J
    .locals 2

    .prologue
    .line 122
    iget-wide v0, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    return-wide v0
.end method

.method public isSessionKeyValid()Z
    .locals 5

    .prologue
    const/4 v0, 0x1

    .line 136
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v1, :cond_1

    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-eqz v1, :cond_1

    .line 137
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    iget-wide v3, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    cmp-long v1, v1, v3

    if-gez v1, :cond_1

    .line 147
    :cond_0
    :goto_0
    return v0

    .line 142
    :cond_1
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    .line 143
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v1, :cond_2

    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-eqz v1, :cond_2

    .line 144
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    iget-wide v3, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    cmp-long v1, v1, v3

    if-ltz v1, :cond_0

    .line 147
    :cond_2
    const/4 v0, 0x0

    goto :goto_0
.end method

.method restoreSessionKey()V
    .locals 5

    .prologue
    .line 160
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->restoreAccessToken()Ljava/lang/String;

    move-result-object v1

    iput-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    .line 163
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    if-eqz v1, :cond_0

    .line 164
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    .line 167
    :cond_0
    :try_start_0
    invoke-direct {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->initSessionKey()V

    .line 169
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v1, :cond_1

    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-eqz v1, :cond_1

    iget-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    cmp-long v1, v1, v3

    if-gez v1, :cond_2

    .line 170
    :cond_1
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    invoke-direct {p0, v1}, Lcom/renren/api/connect/android/AccessTokenManager;->exchangeSessionKey(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 176
    :cond_2
    :goto_0
    return-void

    .line 172
    :catch_0
    move-exception v0

    .line 173
    .local v0, e:Ljava/lang/Exception;
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 174
    invoke-virtual {p0}, Lcom/renren/api/connect/android/AccessTokenManager;->clearPersistSession()V

    goto :goto_0
.end method

.method public setContext(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 126
    iput-object p1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->context:Landroid/content/Context;

    .line 127
    return-void
.end method

.method updateAccessToken(Ljava/lang/String;)V
    .locals 1
    .parameter "accessToken"

    .prologue
    .line 156
    const/4 v0, 0x1

    invoke-direct {p0, p1, v0}, Lcom/renren/api/connect/android/AccessTokenManager;->updateAccessToken(Ljava/lang/String;Z)V

    .line 157
    return-void
.end method

.method public writeToParcel(Landroid/os/Parcel;I)V
    .locals 6
    .parameter "dest"
    .parameter "flags"

    .prologue
    const-wide/16 v4, 0x0

    .line 396
    new-instance v0, Landroid/os/Bundle;

    invoke-direct {v0}, Landroid/os/Bundle;-><init>()V

    .line 397
    .local v0, bundle:Landroid/os/Bundle;
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    if-eqz v1, :cond_0

    .line 398
    const-string v1, "renren_token_manager_access_token"

    iget-object v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->accessToken:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 400
    :cond_0
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    if-eqz v1, :cond_1

    .line 401
    const-string v1, "renren_token_manager_session_key"

    iget-object v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionKey:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 403
    :cond_1
    iget-object v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    if-eqz v1, :cond_2

    .line 404
    const-string v1, "renren_token_manager_session_secret"

    iget-object v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->sessionSecret:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 406
    :cond_2
    iget-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    cmp-long v1, v1, v4

    if-eqz v1, :cond_3

    .line 407
    const-string v1, "renren_token_manager_session_key_expire_time"

    iget-wide v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->expireTime:J

    invoke-virtual {v0, v1, v2, v3}, Landroid/os/Bundle;->putLong(Ljava/lang/String;J)V

    .line 409
    :cond_3
    iget-wide v1, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    cmp-long v1, v1, v4

    if-eqz v1, :cond_4

    .line 410
    const-string v1, "renren_token_manager_user_id"

    iget-wide v2, p0, Lcom/renren/api/connect/android/AccessTokenManager;->uid:J

    invoke-virtual {v0, v1, v2, v3}, Landroid/os/Bundle;->putLong(Ljava/lang/String;J)V

    .line 412
    :cond_4
    invoke-virtual {v0, p1, p2}, Landroid/os/Bundle;->writeToParcel(Landroid/os/Parcel;I)V

    .line 413
    return-void
.end method
